﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AMS.DD35.WebMVP.Views;
using AMS.DD35.Common.Data;
using AMS.DD35.WebMVP.Models;
using AMS.DD35.WebMVP.State;

namespace AMS.DD35.WebMVP.Presenters
{
    public class CharactersPresenter
    {
        ICharactersView _view;
        ICharacterModel _model;
        IStateManager _state;

        public CharactersPresenter(ICharactersView view, ICharacterModel model, IStateManager stateManager)
        {
            this._view = view;
            this._model = model;
            this._state = stateManager;
        }

        public void OpenCharacter()
        {
            // save selected character ID to session state
            _state.CharacterID = _view.SelectedCharacterId;
            // redirect to CharacterView.aspx
            _view.OpenCharacter();
        }

        public void NewCharacter()
        {
            // set invalid character ID
            _state.CharacterID = -1;
            // redirect to CharacterView.aspx
            _view.OpenCharacter();
        }
    }
}